import { _decorator, Component, Node } from 'cc';
import { BattleContext } from './BattleContext';
const { ccclass, property } = _decorator;

@ccclass('Surround')
export class Surround extends Component {

    angleSpeed:number = 3; // 旋转速度
    isMoving:boolean = false; // 是否可以旋转

    protected onEnable(): void {
        for(let i=0;i< this.node.children.length;i++) {
            this.node.children[i].angle = 0 + i * 120; // 设置初始角度
        }
    }

    protected onDisable(): void {
        
    }
    start() {

    }

    update(deltaTime: number) {
        if(!this.isMoving)  return;

        if(BattleContext.ndPlayer) {
            this.node.setWorldPosition(BattleContext.ndPlayer.worldPosition); // 设置父节点位置
        }

        for(let i=0;i< this.node.children.length;i++) {
            this.node.children[i].angle += this.angleSpeed;

        }
    }
}


